<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<title>技术论坛</title>
</head>
<style>
.info a,.info-unreviewed a{color:#333;text-decoration:none;}
</style>
<body>
<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">技术论坛</div>
		</div>

	</div>
	<div class="table-container" data-options="region:'center'">
		<div>
			
		
		<table id="pro_table" class="easyui-datagrid" style="min-height: 100%">
		</table>
		</div>
	</div>
</body>
<script th:inline="javascript">
	var currentPro;
	var currentChild;
	var userInfo =[[${userInfo}]];
	$(document).ready(function() {
		$('#pro_table').datagrid({
			rownumbers : true,
			singleSelect : true,
			pagination : true,
			fitColumns : false,
			border : false,
			striped : true,
			toolbar : '#pro_tb',
			url : "../forumPosts",
			method : 'get',
			queryParams : {
				status : 2,
				name : userInfo.name
			},
			onSelect : function(index,row) {
				currentPro = row;
			},
			columns : [ [ {
				field : 'title',
				title : '帖子主题',
				width : '',
				formatter : function(value,row,index) {
					var html='';
					html+= '<div class="info info-mypro" onclick="toreply(' + index + ')"><div class="info-item-content"><a href="#" >'+value+'</a></div>'
					if (row.updatetime == null){
						html+='<div class="info-time">最后发表：' + formatDate(row.createdate) +'</div>'
					}else{
						html+='<div class="info-time">最后发表：' + formatDate(row.updatetime) +'</div>'
					}
					if (row.user != null){
						html+= '<div class="info-item text-right">作者：'+row.user.name+'</div>'
					}
					html += '<div class="info-content">回复：'+ row.replycount +'</div></div>'
					return html;
				}
			} ] ]
		});
	});
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear();
		var month = date.getMonth() + 1; //月份是从0开始的
		if (month < 10){
			month = "0" + month;
		}
		var day = date.getDate();
		if (day < 10){
			day = "0" + day;
		}
		var hour = date.getHours();
		if (hour < 10){
			hour = "0" + hour;
		}
		var min = date.getMinutes();
		if (min < 10){
			min = "0" + min;
		}
		var sec = date.getSeconds();
		if (sec < 10){
			sec = "0" + sec;
		}
		var newTime = year + '-' + month + '-' + day + ' ' + hour + ':' + min + ':' + sec;
		return newTime;
	}

	function toreply(index) {
		var item = $("#pro_table").datagrid('getRows')[index];
		window.location.href = "../app/toreply.do?postid=" + item.id;
	}
</script>

</html>